var lat;
var lng;
// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398,39.897445);
map.centerAndZoom(point,12);
var geoc = new BMap.Geocoder();
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        var mk = new BMap.Marker(r.point);
        map.addOverlay(mk);
        map.panTo(r.point);
        pt=r.point;
        var city=r.address.city;
        lat=r.point.lat;
        lng=r.point.lng;
        console.log(r.address)
        console.log(city)
        console.log(lat)
        console.log(lng)
        geoc.getLocation(pt, function(rs){
            var addComp = rs.addressComponents;
            var province = addComp.province;
            var city2 = addComp.city;
            var district = addComp.district;
            console.log(province)
            console.log(city2)
            console.log(district)
            var html='';
            $.ajax({
                type: "POST",
                url: href,
                data: {lat:lat,lng:lng},
                dataType: "json",
                success: function (data) {
                    var shore_list=data.data;
                    for(i=0;i<shore_list.length;i++){

                        if(shore_list[i]['id']==shore_id){
                            $('#d_store').html(shore_list[i]['juli']+'km')
                        }else{

                            html=html+'<div onclick=location.href="'+shore_list[i]['href']+'"><span>'+shore_list[i]['store_name']+'</span><span>'+shore_list[i]['juli']+'km</span></div>';
                        }
                    }
                    $('.near').append(html)
                }
            })
        });
    }
    else {
        console.log('failed'+this.getStatus());
    }
},{enableHighAccuracy: true})


function get_store($type) {
    if($type==1){
        $('#content1').hide();
        $('#content2').show();
    }
    if($type==2){
        $('#content1').show();
        $('#content2').hide();
    }

}
